﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dominio;

namespace HotelGUI
{
    public partial class BuscarReservas : Form
    {
        public BuscarReservas()
        {
            InitializeComponent();

            ISistema sistema = Fabrica.getSistema();

            List<string[]> listR = sistema.obtenerReservas();

            int i;

            foreach (string[] reserva in listR)
            {
                if (reserva[3].Equals("Reservado"))
                {
                    i = dgvReservas.Rows.Add();
                    dgvReservas.Rows[i].Cells[0].Value = reserva[0];
                    dgvReservas.Rows[i].Cells[1].Value = sistema.traerCliente(Int32.Parse(reserva[4]))[1];
                    dgvReservas.Rows[i].Cells[2].Value = DateTime.Parse(reserva[1]);
                }
                
            }

        }

        private void dgvReservas_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            ((Reservas)(this.Owner)).setReserva(dgvReservas.Rows[e.RowIndex].Cells[0].Value.ToString());
            this.Close();
        }
        
    }
}
